//
//  MJAdressController.m
//  WeCahtQQLogin
//
//  Created by HappyMilk 02 on 2017/2/9.
//  Copyright © 2017年 HappyMilk 02. All rights reserved.
//

#import "MJAdressController.h"
#import "MJCityController.h"

@interface MJAdressController ()<UITableViewDelegate,UITableViewDataSource>{
    
    NSArray *addressArr;
    NSArray *province;//省
    NSArray *city;//城市
    NSArray *district;//街道
    
}

@property (weak, nonatomic) IBOutlet UITableView *tabelview;



@end

@implementation MJAdressController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *plistPath = [bundle pathForResource:@"city" ofType:@"plist"];
    addressArr = [NSArray arrayWithContentsOfFile:plistPath];
    [self.tabelview reloadData];
    
}
- (IBAction)popvc:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return addressArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellid = @"adrid";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] init];
    }
    cell.textLabel.text = addressArr[indexPath.row][@"state"];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"mine" bundle:nil];
    MJCityController *vc = [sb instantiateViewControllerWithIdentifier:@"MJCityController"];
    vc.cityArray = addressArr[indexPath.row][@"cities"];
    vc.sheng = addressArr[indexPath.row][@"state"];
    [self.navigationController pushViewController:vc animated:YES];
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
